﻿using System;
using System.IO;
using EmailJabber.Logic.Commands.Base;
using EmailJabber.Logic.Logic.BusinessLogic;

namespace EmailJabber.Logic.Commands.FileViewCommands
{
    public class DirCommand : CommandBase
    {

        protected override string GetDecription()
        {
            return "return files in current directory";
        }

        protected override Guid GetId()
        {
            return new Guid("5D7552C4-CD52-4CA8-ACEB-99CE89C58B40");
        }

        protected override void ExecuteSafe(MessageIM comnd)
        {
            string result = string.Empty;
            string[] files = Directory.GetFileSystemEntries(EmailJabber.Core.FileManagemant.FileSystemBlo.Instance.CurrentDir);
            foreach (string fileName in files)
            {
                result = result + fileName + Environment.NewLine;
            }
            BL.Instance.Send(MessageIM.GetReply(EmailJabber.Core.FileManagemant.FileSystemBlo.Instance.CurrentDir,comnd));
            BL.Instance.Send(MessageIM.GetReply(result,comnd));
        }
    }
}